<template>
    <view class="content">
        <view style="z-index: 888;position: fixed;top: 0;overflow: hidden;">
            <view class="notice">
                <img src="/static/homepage/laba.jpg" alt=""
                    style="position: absolute;top:  10rpx;width: 19rpx;height: 20rpx;left: 35.42rpx;line-height: 24rpx;">
                <view class="thing" v-for="item in lists" :key="item.index">
                    {{item.text}}
                </view>
            </view>
            <img  style="height:100% ;width:750rpx;height:843rpx;z-index: 99;" :src="image" alt="">
    
            
        </view>
        <yhdslCropper ref="yhdslCropper" :quality="10" mode="free"  @uploadImg="uploadImg" scale="0.889679715" style="z-index: 99999;">
        </yhdslCropper>
        <!-- 要在pages.json里面把页面默认下拉刷新改为false -->
        <scroll-view scroll-y="true" refresher-default-style="white" refresher-enabled="true"
            :refresher-triggered="triggered" :refresher-threshold="100" refresher-background="transparent"
            @refresherpulling="onPulling" @refresherrefresh="onRefresh" @refresherrestore="onRestore"
            style=" z-index: 999;height: 100vh;">
            <view class="main">
                <view style="height: 35rpx;background-color: transparent;">
                    
                </view>
                <view style="height: 265rpx;background-color: transparent;z-index: 0;" @click="choose">
                </view>
                <!-- 顶部的图片 -->
                <view style="background-color: white;">
                    <div style="display: none;">
                        <div v-for="item in items1" :key="item.id">{{ count }}</div>
                    </div>
                    <!-- 今日课程预览 -->
                    <div class="today">
                        TODAY:
                    </div>
                    <TestCom style="display: none;"></TestCom>
                    <!-- 使用组件TestCom -->
                    <image class="logo" src="/static/logo.png"></image>
                    <text class="title">{{ title }}</text>
                    <!-- <uni-calendar class="uni-calendar--hook" style="display: none;" /> -->
                    <!-- uni-calendar-日历表 -->
                    <view>
                        <div class="todaycoursepre">
                            <div class="blueblock">
                            </div>
                            <div class="todaycourse">
                                今日课程预览
                            </div>
                        </div>
                        <button hover-class="button-hover" @click="openTo('pages/courseTable/courseTable')"
                            class="jinri">

                            <div style="height: 136.5rpx;position: relative;" v-for="item in course" :key="item.index"
                                :class="item.hidden">
                                <div class="bluedot"></div>
                                <div style="position: absolute;top: 37.5rpx; left: 70rpx;line-height: 22.22rpx;text-align: left;height:80rpx ; width: 325rpx;overflow: hidden;">
                                    <div class="coursename" style="display: inline-block;">{{item.coursename}}</div>
                                    <div style="display: inline-block"></div>
                                    <div class="courseplace" style="height: 25rpx;line-height: 25rpx;overflow: hidden;position: absolute;top: 45rpx;">{{item.courseplace}}</div>
                                </div>	
                                <div class="coursetime"> 
                                    <div style="border-bottom:2rpx solid #62ABFA;height: 30rpx;">{{item.coursetime}}
                                    </div>
                                </div>
                            </div>
                        </button>
                        <div class="todaycoursepre">
                            <div class="blueblock" style="background: #EB6877;">
                            </div>
                            <div class="todaycourse" style="color: #EB6877;border-bottom:2rpx solid #EB6877;">
                                TO DO LIST
                            </div>
                            <!-- <tomato class="tomato"></tomato> -->
                        </div>
                        <view class="">
                            <button hover-class="button-hover" @click="openTo('pages/todoList/todoList')" class="todo" style="padding: 0;"
                                >
                                <div style="width:683.33rpx; position:relative;" v-for="item in todo"
                                    :key="item.index">
                                    <div class="pinkdot"></div>
                                    <div style="line-height: 36rpx;height: auto; max-width: 550rpx;">
                                        <div class="todothing"><span style="border-bottom: 3rpx solid #fff;line-height: 50rpx;">{{item.thing}}</span> </div>
                                    </div>
                                    <img src="/static/homepage/clock.png" alt=""
                                        style="position: absolute;top: 34rpx;right:49rpx;width: 100%;height: 100%;width: 55.5rpx;height: 55.5rpx;">
                                </div>
                            </button>
                            <div class="todaycoursepre">
                                <div class="blueblock" style="background:  #FACC31;">
                                </div>
                                <div class="todaycourse" style="color: #FACC31;border-bottom:2rpx solid #FACC31;">
                                    番茄钟
                                </div>
                            </div><!--  -->
                            <button hover-class="button-hover" @click="openTo('pages/tomatoClock/tomatoClock')"
                                class="fanqie">
                                <!-- <div v-for="item in arr1" :style="item.pro" class="Settingbox" >“ 千里之行，始于足下2 ”</div> -->
                                <div class="fighting">
                                    <div class="time">{{Timee}}</div>
                                    <div class="begin">begin!</div>
                                </div>
                                <div class="gundong">
                                    <div class="jitang" v-if="arr.length!=0" ref="parent">
                                        <!-- <div v-for="item in arr"  :key="item.index" :ref="item.active" :style="item.gg" :class="item.active" > {{ item.content }}</div> -->
                                        <div v-for="item in arr" :key="item.index" :id="item.active2" :style="item.gg"
                                            :class="item.active"> {{ item.content }}</div>

                                    </div><!--  -->
                                </div>
                            </button>
                        </view>
                    </view>
                </view>
            </view>
            <view style="height: 100rpx;background-color: transparent;">
            </view>
        </scroll-view>

        <view class="bottom" style="z-index: 2000;">
            <BottomNavigate></BottomNavigate>
        </view>
    </view>

</template>
<script>
    import  yhdslCropper from "./../../../components/yhdsl-cropper/yhdsl-cropper.vue";

    export default {
        components: {
             yhdslCropper
        },
        //cnm非要社里面
        data() {
            return {
                Timee: '25:00',
                title: "Hello",
                items1: ["id:1,text:nihao", ],
                image: '/static/homepage/feiji2.jpg',
                count: 0,
                test: "是否刷新成功？",
                hasLoaded: false,
                triggered: false,
                nihao: '',
                chuxian: '',
                xiaoshi: '',
                isflag: 0,
                tian: '3',
                shijian: '',
                nowWeek: '13',
                flag: false,
                arr1: [{
                    pro: 'display:none;',
                }],
             	arr: [{
							id: 1,
							content: '“ 千里之行，始于足下 ”',
							active: '',
							active2: '',
							gg: ''
						},
						{
							id: 2,
							content: '“ 海纳百川，取则行远 ”',
							active: 'bianda',
							active2: 'div2',
							gg: ''
						},
						{
							id: 3,
							content: '“ 绳锯木断，水滴石穿 ”',
							active: 'bianda',
							active2: 'div3',
							gg: ''
						},
						{
							id: 4,
							content: '“ 千里之行，始于足下 ”',
							active: 'bianda',
							active2: 'div4',
							gg: ''
						},
						{
							id: 5,
							content: '“ 海纳百川，取则行远 ”',
							active: 'bianda',
							active2: 'div5',
							gg: ''
						},
						{
							id: 6,
							content: '“ 绳锯木断，水滴石穿 ”',
							active: '',
							active2: '',
							gg: ''
						},
					],
                course: [{
                        coursename: "课程",
                        coursetime: "时间",
                        courseplace: "地点",
                        hidden: 'divv',
                        courseday:'0',
                    },{
                        coursename: "课程",
                        coursetime: "时间",
                        courseplace: "地点",
                        hidden: 'divv',
                        courseday:'0',
                    },{
                        coursename: "课程",
                        coursetime: "时间",
                        courseplace: "地点",
                        hidden: 'divv',
                        courseday:'0',
                    },{
                        coursename: "课程",
                        coursetime: "时间",
                        courseplace: "地点",
                        hidden: 'divv',
                        courseday:'0',
                    },{
                        coursename: "课程",
                        coursetime: "时间",
                        courseplace: "地点",
                        hidden: 'divv',
                        courseday:'0',
                    },{
                        coursename: "课程",
                        coursetime: "时间",
                        courseplace: "地点",
                        hidden: 'divv',
                        courseday:'0',
                    },{
                        coursename: "课程",
                        coursetime: "时间",
                        courseplace: "地点",
                        hidden: 'divv',
                        courseday:'0',
                    },{
                        coursename: "课程",
                        coursetime: "时间",
                        courseplace: "地点",
                        hidden: 'divv',
                        courseday:'0',
                    },{
                        coursename: "课程",
                        coursetime: "时间",
                        courseplace: "地点",
                        hidden: 'divv',
                        courseday:'0',
                    },{
                        coursename: "课程",
                        coursetime: "时间",
                        courseplace: "地点",
                        hidden: 'divv',
                        courseday:'0',
                    },{
                        coursename: "课程",
                        coursetime: "时间",
                        courseplace: "地点",
                        hidden: 'divv',
                        courseday:'0',
                    },{
                        coursename: "课程",
                        coursetime: "时间",
                        courseplace: "地点",
                        hidden: 'divv',
                        courseday:'0',
                    },{
                        coursename: "课程",
                        coursetime: "时间",
                        courseplace: "地点",
                        hidden: 'divv',
                        courseday:'0',
                    },{
                        coursename: "课程",
                        coursetime: "时间",
                        courseplace: "地点",
                        hidden: 'divv',
                        courseday:'0',
                    },{
                        coursename: "课程",
                        coursetime: "时间",
                        courseplace: "地点",
                        hidden: 'divv',
                        courseday:'0',
                    },{
                        coursename: "课程",
                        coursetime: "时间",
                        courseplace: "地点",
                        hidden: 'divv',
                        courseday:'0',
                    },{
                        coursename: "课程",
                        coursetime: "时间",
                        courseplace: "地点",
                        hidden: 'divv',
                        courseday:'0',
                    },{
                        coursename: "课程",
                        coursetime: "时间",
                        courseplace: "地点",
                        hidden: 'divv',
                        courseday:'0',
                    },{
                        coursename: "课程",
                        coursetime: "时间",
                        courseplace: "地点",
                        hidden: 'divv',
                        courseday:'0',
                    },{
                        coursename: "课程",
                        coursetime: "时间",
                        courseplace: "地点",
                        hidden: 'divv',
                        courseday:'0',
                    },{
                        coursename: "课程",
                        coursetime: "时间",
                        courseplace: "地点",
                        hidden: 'divv',
                        courseday:'0',
                    },{
                        coursename: "课程",
                        coursetime: "时间",
                        courseplace: "地点",
                        hidden: 'divv',
                        courseday:'0',
                    },{
                        coursename: "课程",
                        coursetime: "时间",
                        courseplace: "地点",
                        hidden: 'divv',
                        courseday:'0',
                    },{
                        coursename: "课程",
                        coursetime: "时间",
                        courseplace: "地点",
                        hidden: 'divv',
                        courseday:'0',
                    },{
                        coursename: "课程",
                        coursetime: "时间",
                        courseplace: "地点",
                        hidden: 'divv',
                        courseday:'0',
                    },{
                        coursename: "课程",
                        coursetime: "时间",
                        courseplace: "地点",
                        hidden: 'divv',
                        courseday:'0',
                    },{
                        coursename: "课程",
                        coursetime: "时间",
                        courseplace: "地点",
                        hidden: 'divv',
                        courseday:'0',
                    },{
                        coursename: "课程",
                        coursetime: "时间",
                        courseplace: "地点",
                        hidden: 'divv',
                        courseday:'0',
                    },{
                        coursename: "课程",
                        coursetime: "时间",
                        courseplace: "地点",
                        hidden: 'divv',
                        courseday:'0',
                    },{
                        coursename: "课程",
                        coursetime: "时间",
                        courseplace: "地点",
                        hidden: 'divv',
                        courseday:'0',
                    },{
                        coursename: "课程",
                        coursetime: "时间",
                        courseplace: "地点",
                        hidden: 'divv',
                        courseday:'0',
                    },{
                        coursename: "课程",
                        coursetime: "时间",
                        courseplace: "地点",
                        hidden: 'divv',
                        courseday:'0',
                    },{
                        coursename: "课程",
                        coursetime: "时间",
                        courseplace: "地点",
                        hidden: 'divv',
                        courseday:'0',
                    },{
                        coursename: "课程",
                        coursetime: "时间",
                        courseplace: "地点",
                        hidden: 'divv',
                        courseday:'0',
                    },{
                        coursename: "课程",
                        coursetime: "时间",
                        courseplace: "地点",
                        hidden: 'divv',
                        courseday:'0',
                    },{
                        coursename: "课程",
                        coursetime: "时间",
                        courseplace: "地点",
                        hidden: 'divv',
                        courseday:'0',
                    },{
                        coursename: "课程",
                        coursetime: "时间",
                        courseplace: "地点",
                        hidden: 'divv',
                        courseday:'0',
                    },{
                        coursename: "课程",
                        coursetime: "时间",
                        courseplace: "地点",
                        hidden: 'divv',
                        courseday:'0',
                    },{
                        coursename: "课程",
                        coursetime: "时间",
                        courseplace: "地点",
                        hidden: 'divv',
                        courseday:'0',
                    },{
                        coursename: "课程",
                        coursetime: "时间",	
                        courseplace: "地点",
                        hidden: 'divv',
                        courseday:'0',
                    },

                ],
                courselength: '',
                todo: [{
                    "id": 6,
                    "thing": "点击添加Todo事件",
                    "thing_state": 1,
                    "thing_priority": 2,
                    "time": "1991-08-27 07:58:48",
                    "user": 3,
                }, ],
                todoheight: '',
                thisflag: 0,
                dada: '',
                lists: [{
                    text: '暂时没有通知',
                }],
            };
        },
    
        created() {
            console.log('created');
        },
        onShow() {
            this.onRefresh()
            console.log('onshow');
            this.abc()
            this.getTodo();
            // console.log('存一下');
            // console.log(this.isflag);
            if (uni.getStorageSync('isflag')) {
                console.log(uni.getStorageSync('thing'));
                this.todo[0].thing = uni.getStorageSync('thing');
            }
            if (this.isflag) {
            this.lists[0].thing = uni.getStorageSync('text');
            }
            if(this.isflag==1)
            {if(uni.getStorageSync('mainPageimg')!=''){this.image= uni.getStorageSync('mainPageimg');}}
            
            // this.flag=uni.getStorageSync('flag');	
            // this.courselength=uni.getStorageSync('courselength');
            // console.log(this.courselength);
            // console.log('今天有'+this.cours	elength+'节课');	
        },
        onLoad() {
            this.isflag = uni.getStorageSync('isflag')
            // this.course=uni.getStorageSync('course');
            // 标记页面已经初次加载过 
            console.log(this.isflag);
            console.log('存flag');
            if (this.isflag) {
                this.course = uni.getStorageSync('course');
                if(uni.getStorageSync('mainPageimg')!='')
                {this.image=uni.getStorageSync('mainPageimg')}
            }
            console.log(this.image);
            setInterval(this.proo, 8000)
            // this.course=uni.getStorageSync('course');	
            //这里出的错误，每次第一次存的时候就会出错
            console.log('保存成功');
            console.log('onload');
            this.hasLoaded = true;
            this.triggered = false;
            if (this.hasLoaded == true) {
                setTimeout(() => {
                    this.triggered = true;
                }, 1000)
            }
            
            // uni.setStorageSync('flag', this.flag)
            // this.panduan();
            // setInterval(function() {
            // 	this.bianhuan()
            // }, 2000);
            // setInterval(function() {
            // 	this.bianhuan1()
            // }, 8000);
            this.getTime();
            console.log('this.tian'+this.tian);
            this.getList();
        },
        onUnload() {
            // 保存状态
        },
        onReady() {

        },
        //这里加上onload是为了不让页面在开始的时候自动刷新，所以加了个hasloaded进行判断
        
        methods: {
            onPullDownRefresh() {
                // uni.startPullDownRefresh();
                //下面是下拉刷新页面的相关代码
                //...
                // setTimeout(()=>{
                //     this.$refs.msg1.showMsg(2,"刷新成功");
                // },1000)
                uni.stopPullDownRefresh();
                
            },
            abc() {
                var a = uni.getStorageSync('time');
                console.log(uni.getStorageSync('time'));
                var b = Math.floor(a / 60); // 将除数改为Math.floor()函数向下取整
                var c = a % 60;
                if (b == '') {
                    b = '25';
                }
                c = parseInt(c);
                if (c == 0) {
                    c = '00'; // 将单个数字补齐两位数
                } else if (c > 0 && c < 10) {
                    c = '0' + c;
                }
                if (b == 0) {
                    b = '00'; // 将单个数字补齐两位数
                } else if (b > 0 && b < 10) {
                    b = '0' + b;
                }
                this.Timee = b + ':' + c;
                uni.setStorageSync('Timee', this.Timee);
            },
            proo() {
                this.arr1[0].pro = 'display:block;font-size:33.3rpx;';


            },
            onloadImg() {
                var biaoji=0;
                uni.chooseImage({ //选择图片
                    count: 1,
                    sizeType: ["compressed"],
                    success(res) {
                        // console.log('你好切换图片');
                        this.image = res.tempFiles[0].path
                        uni.setStorageSync('mainPageimg', this.image)
                        // this.imgsFile = res.tempFilePaths[0]; //获取图片的临时资源
                        // uni.setStorageSync('imgsFile', this.imgsFile) //存到本地缓存
                        this.image = uni.getStorageSync('mainPageimg');
                        console.log(this.image);
                         biaoji=1;
                         uni.redirectTo({
                             url: "pages/index/indexPage/indexPage",
                         })
                         //打印变量
                    }
                })

                
            },
            choose() {
                        // 调用实例的chooseImg方法，拉起图片选择界面，待图片选择完毕后直接进入图片截取界面
                        this.$refs.yhdslCropper.chooseImage()
                    },
                    // 裁剪完成时,返回截取图片的临时路径
            uploadImg(e) {
                        this.url = e;	
                        this.image=this.url;
                                     uni.setStorageSync('mainPageimg',this.image);
                    } ,   
            getTopOffset() {
                var parent = 1;
                var div1 = 1;
                var nihao = 1;
                var query = uni.createSelectorQuery().in(this);
                query.select('.gundong').boundingClientRect((rect) => {
                    var childTopOffset = rect.top;
                    parent = childTopOffset;

                    var query1 = uni.createSelectorQuery().in(this);
                    query1.select('#div2').boundingClientRect((rect1) => {
                        var childTopOffset1 = rect1.top;

                        div1 = parseInt(childTopOffset1);

                        nihao = div1 - parent;

                        if (nihao > 20 && nihao < 50) {
                            this.arr[1].active = 'bianda';
                        } else {
                            this.arr[1].active = '';
                        }
                    }).exec();
                }).exec();
                query = uni.createSelectorQuery().in(this);
                query.select('.gundong').boundingClientRect((rect) => {
                    var childTopOffset = rect.top;
                    parent = childTopOffset;

                    var query1 = uni.createSelectorQuery().in(this);
                    query1.select('#div3').boundingClientRect((rect1) => {
                        var childTopOffset1 = rect1.top;
                        div1 = parseInt(childTopOffset1);

                        nihao = div1 - parent;

                        if (nihao > 20 && nihao < 50) {
                            this.arr[2].active = 'bianda';

                        } else {
                            this.arr[2].active = '';
                        }
                    }).exec();
                }).exec();
                query = uni.createSelectorQuery().in(this);
                query.select('.gundong').boundingClientRect((rect) => {
                    var childTopOffset = rect.top;
                    parent = childTopOffset;
                    var query1 = uni.createSelectorQuery().in(this);
                    query1.select('#div4').boundingClientRect((rect1) => {
                        var childTopOffset1 = rect1.top;

                        div1 = parseInt(childTopOffset1);

                        nihao = div1 - parent;

                        if (nihao > 20 && nihao < 50) {
                            this.arr[3].active = 'bianda';

                        } else {
                            this.arr[3].active = '';
                        }
                    }).exec();
                }).exec();
                query = uni.createSelectorQuery().in(this);
                query.select('.gundong').boundingClientRect((rect) => {
                    var childTopOffset = rect.top;
                    parent = childTopOffset;


                    var query1 = uni.createSelectorQuery().in(this);
                    query1.select('#div5').boundingClientRect((rect1) => {
                        var childTopOffset1 = rect1.top;
                        div1 = parseInt(childTopOffset1);
                        nihao = div1 - parent;

                        if (nihao > 20 && nihao < 50) {
                            this.arr[4].active = 'bianda';
                        } else {
                            this.arr[4].active = '';
                        }
                    }).exec();
                }).exec();

                //拿到两个高可以知道差值

            },
            getItems() {
                // 获取数据 
                this.test = "成功刷新";
                console.log(this.test);
                // 在获取数据完成后，调用 wx.stopPullDownRefresh() 停止下拉刷新动画
                wx.stopPullDownRefresh();
            },
            openTo(url) {
                uni.navigateTo({
                    url
                })
            },
            panduan() {
                for (var i = 0; i < this.arr.length - 1; i++) {
                    if (this.arr[i].id == 2) {
                        this.arr[i].gg = 'font-size:33.3rpx;opacity: 1;'
                    }
                }
            },
            bianhuan() {
                        this.arr[1].active = 'bianda1'
            },
            bianhuan1() {
            this.arr[1].active = ''
                
            },
            onPulling(e) {
                
            },
            onRefresh() {
        
            console.log('刷新');
                // if (this._freshing) return;
                this._freshing = true;
                this.triggered = true;
                setTimeout(() => {
                    this.triggered = false;
                    this._freshing = false;
                    uni.stopPullDownRefresh();
                }, 1000)
                
            },
            onRestore() {
                this.triggered = 'restore'; // 需要重置
                console.log("onRestore");
            },
            onAbort() {
                console.log("onAbort");
            },
            da() {
                var a = this.course.length;
                var b = a * 136.5;
                this.dada = 'brpx'
                // 这里用不用this.b都可以
            },
            todoHightChange() {
                var c = this.todo.length;
                var d = c * 136.5;
                this.todoheight = 'drpx'
                // 这里用不用this.b都可以
            },
            getTime() {
                let a = new Date();
                this.shijian = a.getDay();
                console.log('时间是' + this.shijian);
                this.tian = this.shijian;
            },
            getTodo() {
                uni.request({
                    url: 'https://tomato.daoxuan.cc/todo/',
                    header: {
                        Accept: 'application/json',
                        'Content-Type': 'application/json',
                        'X-Requested-With': 'XMLHttpRequest',
                        "Authorization": "Bearer " + uni.getStorageSync('login').access
                    },
                    method: 'GET',
                    sslVerify: true,
                    success: ({
                        data,
                        statusCode,
                        header
                    }) => {
                        // var dateTimeString ="1991-08-27 07:58:48";
                        // var dateTimeArray = dateTimeString.split(/[\s-:]/);
                        // var dateTimeNumbers = dateTimeArray.map(numString => parseInt(numString, 10));
                        // var dateTimeClean = dateTimeNumbers.join("");
                        // console.log(dateTimeClean);
                        //获得了很多个data
                        // 	var dateTimeString1 = "1991-08-27 07:58:48";
                        // 	var dateTimeArray1 = dateTimeString1.split(/[\s-:]/);
                        // 	var dateTimeNumbers1 = dateTimeArray1.map(numString => parseInt(numString, 10));
                        console.log(data);
                        var thingnum = 0;	
                        // console.log(data);
                        // console.log('什么东西');
                        for (var i = 0; i < data.length; i++) {
                            if (data[i].thing_state != 2) {
                                thingnum = 1; 
                            }  
                        }
                        console.log('thingnumd的值是' + thingnum);
                        if (thingnum==1) {
                            console.log(thingnum);
                            var num = 0;
                            var flag = 0;
                            for (var i = 0; i < data.length; i++) {
                                if (data[i].time != '') {
                                    flag = 1;
                                }
                            }
                            if (flag == 0) {
                                this.todo[0].thing = data[0].thing;
                            }
                            //有了时间之后这里要改变
                            if (flag==1) {
                                var thing3num = 0;
                                for (var i = 0; i < data.length; i++) {
                                    if (data[i].thing_priority == 10) {
                                        thing3num++;
                                        num = 10;
                                    }
                                }
                                console.log(thing3num+'的值是');
                                if (thing3num == 0) {
                                    for (var i = 0; i < data.length; i++) {
                                        if (data[i].thing_priority == 9) {
                                            thing3num++;
                                            num = 9;
                                        }
                                    }
                                    if (thing3num == 0) {
                                        for (var i = 0; i < data.length; i++) {
                                            if (data[i].thing_priority == 8) {
                                                thing3num++;
                                                num = 8;
                                            }
                                        }
                                    }
                                }
                                var k = 0;
                                var a = new Array(thing3num);
                                var b = new Array(thing3num);
                                //一开始有语法错误，k写到了循环里面导致每一次循环都是给a[0]赋值
                                console.log(num+'是');
                                if (num == 10) {
                                    for (var i = 0; i < data.length; i++) {
                                        if (data[i].thing_priority == 10) {
                                            a[k] = data[i].time;
                                            b[k] = data[i].id;
                                            k++;
                                        }
                                    }
                                }
                                if (num == 9) {
                                    for (var i = 0; i < data.length; i++) {
                                        if (data[i].thing_priority == 9) {
                                            a[k] = data[i].time;
                                            b[k] = data[i].id;
                                            k++;
                                        }
                                    }
                                }
                                if (num == 8) {
                                    for (var i = 0; i < data.length; i++) {
                                        if (data[i].thing_priority == 8) {
                                            a[k] = data[i].time;
                                            b[k] = data[i].id;
                                            k++;
                                        }
                                    }
                                }

                                var j = 0;
                                for (var i = 0; i < thing3num - 1; i++) {
                                    for (j = 0; j < thing3num - 1 - i; j++) {
                                        var dateTimeString1 = a[j];
                                        var dateTimeArray1 = dateTimeString1.split(/[\s-:]/);
                                        var dateTimeNumbers1 = dateTimeArray1.map(numString1 => parseInt(
                                            numString1,
                                            10));
                                        var dateTimeNumbers1 = dateTimeArray1[0] + dateTimeArray1[1] +
                                            dateTimeArray1[
                                                2] + dateTimeArray1[3] + dateTimeArray1[4]+ dateTimeArray1[5];
                                                // console.log(dateTimeNumbers1);
                                        var dateTimeString2 = a[j + 1];
                                        var dateTimeArray2 = dateTimeString2.split(/[\s-:]/);
                                        var dateTimeNumbers2 = dateTimeArray2.map(numString2 => parseInt(
                                            numString2,
                                            10));
                                            var dateTimeNumbers2 = dateTimeArray2[0] + dateTimeArray2[1] +
                                            dateTimeArray2[2] + dateTimeArray2[3] + dateTimeArray2[4]+ dateTimeArray2[5];
                                            // console.log(dateTimeNumbers2);
                                        if (parseInt(dateTimeNumbers1) > parseInt(dateTimeNumbers2)) {
                                             // 可以运行的但是当post的时候失败就会失误
                                            var temp = a[j];
                                            var temp1 = b[j];
                                            a[j] = a[j + 1];
                                            b[j] = b[j + 1];
                                            a[j + 1] = temp;
                                            b[j + 1] = temp1;
                                        }
                                    }
                                }
                             console.log(a[0]);
                                for (var i = 0; i < data.length; i++) {
                                    if (data[i].id == b[0]) {
                                        this.todo[0].thing = data[i].thing;
                                        uni.setStorageSync('thing', data[i].thing);
                                    }
                                }

                                let now = new Date();
                                let minutes = now.getMinutes();
                                let hours = now.getHours();
                                if (hours < 10) {
                                    hours = '0' + hours;
                                }
                                let year = now.getFullYear();
                                let month = now.getMonth() + 1;
                                if (month < 10) {
                                    month = '0' + month;
                                }
                                let day = now.getDate();
                                if (day < 10) {
                                    day = '0' + day;
                                }
                                var second = '';
                                let currentTime = year + "-" + month + "-" + day + " " + hours + ":" +
                                    minutes + ":" +
                                    second;
                                var dateTimeString1 = currentTime;
                                var dateTimeArray1 = dateTimeString1.split(/[\s-:]/);
                                var dateTimeNumbers1 = dateTimeArray1.map(numString1 => parseInt(numString1,
                                    10));
                                var dateTimeNumbers1 = dateTimeArray1[0] + dateTimeArray1[1] + dateTimeArray1[
                                        2] +
                                    dateTimeArray1[3] + dateTimeArray1[4] + dateTimeArray1[5];
                                // console.log(parseInt(dateTimeNumbers1));
                                var dateTimeString2 = a[0];
                                var dateTimeArray2 = dateTimeString2.split(/[\s-:]/);
                                var dateTimeNumbers2 = dateTimeArray2.map(numString2 => parseInt(numString2,
                                    10));
                                    
                                var dateTimeNumbers2 = dateTimeArray2[0] + dateTimeArray2[1] + dateTimeArray2[
                                        2] +
                                    dateTimeArray2[3] + dateTimeArray2[4];
                                // console.log(parseInt(dateTimeNumbers2));

                                // console.log(now);
                                // console.log(dateTimeNumbers1);
                                // console.log(dateTimeNumbers2);
                                
                                if (parseInt(dateTimeNumbers1) >= parseInt(dateTimeNumbers2)) {
                                    this.lists[0].text = this.todo[0].thing;
                                    console.log('有没有');
                                    uni.setStorageSync('text', this.todo[0].thing)
                                } else {
                                    var a = '暂时没有通知'
                                    uni.setStorageSync('text', a)
                                }
                            }
                            var flag = true;
                            uni.setStorageSync('flag', flag)
                        } else if(thingnum=='0'){
                            var b = '点击添加Todo事件';
                            // console.log(b);
                            uni.setStorageSync('thing', b);
                                uni.setStorageSync('text', '暂时没有通知');
                             this.todo[0].thing='点击添加Todo事件';
                             this.lists[0].text='暂时没有通知'
                        }
                        console.log('有一次');
                        // this.todo[0].thing=a[0];
                        //此时b[thing3num-1]对应的id为最紧急的事件
                        // this.userData.avatarUrl=data.file_url
                    },
                    fail: (error) => {}
                })
            },
            getList() {
                // uni.request({
                // 	url: 'https://tomato.daoxuan.cc/todo/',
                // 	data: {
                // 	},
                // 	headers:{
                // 		"Authorization":"Bearer "+uni.getStorageSync('login').access
                // 	},method: 'GET',
                //                  sslVerify: true,
                // success: ({ data, statusCode, header }) => {
                //  console.log(data); 
                //  console.log(statusCode);
                //  console.log(header);
                // 		console.log('request successful');
                // 	}
                // });

                uni.request({
                    url: 'https://tomato.daoxuan.cc/timetable/',
                    header: {
                        Accept: 'application/json',
                        'Content-Type': 'application/json',
                        'X-Requested-With': 'XMLHttpRequest',
                        "Authorization": "Bearer " + uni.getStorageSync('login').access
                    },
                    method: 'GET',
                    sslVerify: true,
                    success: ({
                        data,
                        statusCode,
                        header
                    }) => {
                        
                        uni.setStorageSync("courseTable", data)
                        this.isflag = 1;
                        uni.setStorageSync("isflag", this.isflag)
                        console.log(uni.getStorageSync('courseTable'));
                        //别删，这里课表要用
                        console.log('存课表');
                        this.nowWeek = data.weekID;
                        // 得到了数据之后将这里反注释即可
                        console.log(data.data);
                        var courselength = 0;
                        for(var i=0;i<data.data.length;i++)
                        {
                            this.course[i].courseday=data.data[i].date;
                        }
                        
                        
                        for (var i = 0; i < data.data.length; i++) {
                            if (this.tian == data.data[i].date)
                                courselength++;
                                console.log('courselength的值是'+courselength);
                        }
                        console.log(courselength);
                        if (courselength == 0) {
                            this.course[0].hidden = '';
                            this.course[0].coursename = '课程';
                            this.course[0].coursetime = '时间';
                            this.course[0].courseplace = '地点';
                            for (var i = 1; i < data.data.length; i++) {
                                this.course[i].hidden = 'divv';
                            }
                            //这里是因为从有课的一天到没课的一天的时候会仍然显示上一天的课，所以需要将其他课进行隐藏并且将状态保存到本地缓存中
                        } else {
                            this.courselength = courselength;
                            uni.setStorageSync('courselength', courselength)
                        
                            for (var j = 0; j < data.data.length; j++) {
                                // if(this.tian==data[i].date){
                                if (this.tian == data.data[j].date) {
                                    // console.log(data[j].course);
                                    this.course[j].coursename = data.data[j].course;
                                    // console.log(data[j].location);
                                    this.course[j].courseplace = data.data[j].location;
                                    this.course[j].coursetime = data.data[j].time;
                                    // console.log(this.course[j].coursetime);	
                                    
                                }
                            
                            }
                            // }  
                           var p=0;
                            for (var i = 0; i < data.data.length; i++) {

                                var nowWeek = parseInt(this.nowWeek);

                                var str2 = data.data[i].week;
                                var num3 = str2.match(/\d+(\.\d+)?/g);
                                //js提取出字段中的数字装在数组num3中
                                console.log(nowWeek);
                                var beginWeek = parseInt(num3[0]);
                                // console.log(beginWeek);
                                var endWeek = parseInt(num3[1]);
                                // console.log(endWeek);
                                var num4 = str2.match(/[^\d\.]/g);
                            
                                //js提取出字段中的中文装在数组num4中
                                // console.log(num4);
                                // if(this.tian==data[i].date){
                                if (this.course[i].coursename != '课程') {
                                    if (nowWeek >= beginWeek && nowWeek <= endWeek) {
                                        this.course[i].hidden = 'meiyou';
                                    }
                                    // console.log(this.course[i].hidden);
                                }	
                                if (nowWeek % 2 == 0) {
                                    if (num4[1] == '单') {
                                        this.course[i].hidden = 'divv';
                                        this.course[i].coursename =  '课程';
                                    }
                                    //如果有单周的课，那么让这个课消失而现在又是双周那么让这个课消失
                                }
                                if (this.course[i].coursename != '课程') {
                                    if (nowWeek >= beginWeek && nowWeek <= endWeek) {
                                        this.course[i].hidden = 'meiyou';
                                    }
                                        if(this.course[i].courseday!=this.tian)
                                        {
                                            this.course[i].hidden='divv'
                                        }
                                    // console.log(this.course[i].hidden);
                                    //如果有不等于课程的课那么就让这个盒子出现，否则，让这个盒子消失
                                }
                                else if(this.course[i].coursetime == '时间')
                                {
                                    this.course[i].hidden='divv';
                                    console.log(this.course[0].hidden);
                                }
                            }
                            var rlag=0;
                            for(var l=0;l<data.data.length;l++)
                            {
                                if(this.course[l].coursename != '课程')
                                {
                                    rlag++
                                }
                                console.log(rlag);
                            }
                            // 如果今天只有单周的课那么这节课的名字变为课程并且消失，再检测一遍如果全部课的名字都是课程
                            //那么显示课程
                            //如果今天有课那么就不显示这个课程
                            if(rlag==0)
                            {
                                this.course[0].hidden = 'meiyou';
                                this.course[0].coursename = '课程';
                                this.course[0].coursetime = '时间';
                                this.course[0].courseplace = '地点';
                            }
                    
                            // this.course[1].coursename= data[1].course;
                            // this.userData.avatarUrl=data.file_url
                            //字符7显示的是白色，数字7显示的是
                        }
                        for(var i=0;i<data.data.length;i++)
                        {console.log(this.course[i].hidden);
                        console.log(this.course[i].coursename);
                        }
                        
                        console.log('你好');
                        uni.setStorageSync('course', this.course);

                    },
                    fail: (error) => {}
                })

            },

        },
        mounted() {

            let that = this;
            that.da();
            
            // setInterval(this.bianhuan, 8000);
            // setInterval(this.bianhuan1, 8500);
            setInterval(this.getTopOffset, 50);

        },


    };
</script>
<style scoped>
    /* 引入了字体
     步骤：
     1.在网站https://transfonter.org/中勾选Base64 encode然后上传字体文件，点击转换convert
     下载并拿出转换好的css文件放在font里面即可
     @import url("~@/static/font/stylesheet.css");用绝对路径法指向这个css即可
     ./指向的是当前文件，~@是绝对路径法
     并且引用这个css文件要放到使用相应的fontfamily字体上面
     */
    /* @import url("./stylesheet.css"); */
    .Settingbox {
        position: absolute;
        top: 120rpx;
        right: 34rpx;
        font-family: Smiley Sans;
        color: #007AFF;
        line-height: 22rpx;

    }

    .hezi {
        display: none;
    }

    .nihao {
        max-height: 35rpx;
        font-size: 33.3rpx;
    }

    .bianda {
        font-size: 33.3rpx;
    }

    .begin {
        z-index: 10000;
        height: 25.69rpx;
        width: 141rpx;
        font-size: 36rpx;
        font-family: Dotties Chocolate1;
        letter-spacing: 1rpx;
        color: #FACC31;
        line-height: 9.7222rpx;
        margin: 16.66rpx auto 0 auto;
        text-align: center;
        text-shadow: 0px 6.944rpx 0px #E5E5E5;
    }

    .thing {
        height: 13rpx;
        font-size:20rpx;
        font-family: Smiley Sans;
        font-weight: normal;
        position: absolute;
        left: 60rpx;
        color: #F7F7F7;
        line-height: 40rpx;
    }

    .notice {
        width: 750rpx;
        height: 35rpx;
        background: #007AFF;
        position: relative;
    }

    .tomato {
        position: absolute;
        top: 257rpx;
        left: 35.9rpx;
        width: 219rpx;
        height: 219rpx;
        z-index: 0;
    }

    #divv {
        display: none;
    }

    .divv {
        display: none;
    }

    .todothing {
    padding-top: 37.5rpx;
            margin-left: 109rpx;
        margin-bottom: 50rpx;
        font-size: 33.3rpx;
        color: #FFFFFF;
        font-family: Smiley Sans;
        font-weight: normal;
        letter-spacing: 2rpx;
        text-align: left;    
        
    }

    .pinkdot {
        position: absolute;
        width: 31rpx;
        height: 31rpx;
        background: #fff;
        border: 12.5rpx solid #EB6877;

        border-radius: 50%;
        top: 32.6rpx;
        left: 28.47rpx;
    }

    .courseplace {
        font-size: 27.6rpx;
        font-family: Smiley Sans;
        font-weight: normal;
        padding-top: 8.5rpx;
        color: #E5E5E5;
        text-align: left;
    }

    .bluedot {
        position: absolute;
        width: 31rpx;
        height: 31rpx;
        background: #fff;
        border: 12.5rpx solid #007AFF;
        border-radius: 50%;
        top: 32.6rpx;
    }

    .coursetime {
        position: absolute;
        top: 38.8rpx;
        left: 422rpx;
        width: 150rpx;
        font-size: 33.3rpx;
        font-family: Smiley Sans;
        font-weight: normal;
        border-radius: 12.5rpx;
        color: #62ABFA;
        background-color: #fff;
        padding: 20rpx 25.7rpx 15rpx 25.7rpx;
        line-height: 22.2rpx;
        letter-spacing: 2rpx;
    }

    .coursename {
        font-size: 33.3rpx;
        color: #FFFFFF;
        font-family: Smiley Sans;
        height: 43rpx;
        line-height: 43rpx;
        font-weight: normal;
        letter-spacing: 2rpx;
        text-align: left;
        border-bottom: 2rpx solid #fff;
    }

    .jitang div {}

    .gundong {
        height: 190rpx;
        font-size: 25rpx;
        top: 40rpx;
        overflow: hidden;
        right: 34rpx;
        width: 302rpx;
        position: absolute;
        font-family: Smiley Sans;
        color: #007AFF;
    }

    @keyframes scroll {
        20% {
            margin-top: 0;

        }

        ,
        45% {
            margin-top: -75rpx;
        }

        ,
        70% {
            margin-top: -130rpx;
        }

        ,
        90% {
            margin-top: -190rpx;
        }

        ,
        100% {
            margin-top: -190rpx;
        }
    }

    .jitang {
        animation: scroll 8s infinite;
        /* font-size: 33.33rpx; */
        /* top: 40rpx; */
        height: 170rpx;
        font-size: 25rpx;
        width: 302rpx;
        font-family: Smiley Sans;
        /* position: absolute; */
        /* right: 34rpx; */
        color: #007AFF;
    }

    .jinri {
        width: 683.33rpx;
        background: linear-gradient(270deg, #318BF7, #80BCFD);
        border-radius: 33.33rpx;
    }

    .todo {
        width: 683.33rpx;
        background: linear-gradient(270deg, #FFE0E4, #EB6877);
        border-radius: 33.33rpx;
        height: auto;
    }

    .begin {
        height: 25.69rpx;
        width: 141rpx;
        font-size: 36rpx;
        font-family: Dotties Chocolate1;
        letter-spacing: 1rpx;
        color: #FACC31;
        line-height: 9.7222rpx;
        margin: 16.66rpx auto 0 auto;
        text-align: center;
        text-shadow: 0px 6.944rpx 0px #E5E5E5;
    }

    .time {
        margin: 83.3rpx auto 0 auto;
        letter-spacing: 1rpx;
        height: 27.7rpx;
        font-size: 54rpx;
        font-family: Dotties Chocolate1;
        font-weight: normal;
        color: #FACC31;
        line-height: 9.7222rpx;
        text-shadow: 0px 6.944rpx 0px #E5E5E5;
    }

    .fighting {
        position: absolute;
        top: 18.7rpx;
        left: 30.5rpx;
        width: 206rpx;
        height: 206rpx;
        background: #fff;
        border: 12.5rpx solid #FACC31;
        border-radius: 50%;
    }

    .fanqie {
        position: relative;
        width: 683.33rpx;
        height: 266rpx;
        background-image: linear-gradient(-45deg, #FFFFFF 63%, #FACC31 63%, #FACC31 66%, #318BF7 66%);
        border-radius: 33.333rpx;
    }

    .todaycoursepre {
        margin-top: 46.5rpx;
        height: 31rpx;
        position: relative;
        margin-bottom: 13.1rpx;
    }

    .blueblock {
        position: absolute;
        display: inline-block;
        width: 19.444rpx;
        height: 29rpx;
        background: #007AFF;
        border-radius: 9.72rpx;
        margin-left: 35.4rpx;
    }

    .todaycourse {
        position: absolute;
        left: 61.14rpx;
        height: 29rpx;
        font-size: 25rpx;
        font-family: Smiley Sans;
        font-weight: normal;
        color: #007AFF;
        display: inline-block;
        border-bottom: 2rpx solid #007AFF;
        line-height: 22.2222rpx;
    }

    .today {
        width: 234rpx;
        height: 47rpx;
        margin-left: 34rpx;
        padding-top: 33.3rpx;
        font-size: 50rpx;
        font-family: Dotties Chocolate1;
        font-weight: normal;
        text-decoration: underline;
        color: #007AFF;
        line-height: 40rpx;
    }

    .top {
        position: relative;
        height: 276rpx;
    }

    .plane {
        position: absolute;
        top: 0;
        z-index: -12312;
        height: 276rpx;
        width: 750rpx;
        overflow: hidden;
    }

    .plane img {
        height: 100%;
    }

    .main {
        overflow-x: scroll;
        width: 100%;
        margin-bottom: 100rpx;
    }

    .bottom {
        position: fixed;
        bottom: 0;
        width: 100%;
        height: 100rpx;
        background-color: #fff;
        display: flex;
    }

    .content {
        display: flex;
        flex-direction: column;
        /* align-items: center;
    justify-content: center; */
        height: 100%;
        position: relative;
    }

    .logo {
        display: none;
        height: 200rpx;
        width: 200rpx;
        margin: 200rpx auto 50rpx auto;
    }

    .text-area {
        display: flex;
        justify-content: center;
    }

    .title {
        display: none;
        font-size: 36rpx;
        color: #8f8f94;
    }
</style>